package com.fd.controller;

import com.fd.confing.RedisConfig;
import com.fd.confing.Teacher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class IndexController {
    //测试通过JAVA配置模式验证Bean是否存在
    @Autowired
    private RedisConfig redisConfig;

    @Autowired
    private Teacher teacher;

    @RequestMapping("/")
    public String test()throws Exception {
        log.warn("這裡是首頁進入");
        log.error("這裡是錯誤信息！");
        return "Hello F2135!"/*+redisConfig.getVersion()*/+"teacherName:"+teacher.getName();
    }

    @RequestMapping("/fderror")
    @ResponseBody
    public String error() throws Exception {
        int i=1/0;
        return "error page";
    }
}